A processor, e.g., a microprocessor, central processing unit (CPU), etc., controls the operation of many devices, e.g., calculators, computer systems, cellular phones, etc. Processors vary in many ways, e.g., instruction set, word size, and clock speed, etc. Processor word size specifies the number of bits of data a processor is able to store in a processor storage location, i.e., a data register, at one time. For example, early processors used in personal computers had word sizes of 8 bits, i.e., the processors were able to store 8 bits of data at a time. Similarly, more recent 16, 32, and 64 bit processors are able to store 16, 32, and 64 bits of data at a time, respectively.
Processors operate on data in binary form, i.e., ones and zeroes arranged to specify numbers based on powers of two. In order for a processor to operate on a number, the processor converts the number to a binary representation. It is known in the art to encode decimal numbers into a binary representation. For example, the decimal numbers 5 and 235 can be represented using the binary values 0101 and 1110 1011, respectively. However, encoding a decimal number to a binary representation requires a certain amount of processing time in terms of processor operations needed to convert the number from one form to the other. Therefore, alternate encoding techniques have been applied to minimize the amount of processing required for the decimal to binary encoding and decoding.
Further, the number value may increase beyond the storage capability of a single processor word, e.g., the number 256 requires 9 binary digits for representation and uses two words of an 8 bit processor for storage and operation thereon.
One basic alteration of this encoding is binary coded decimal (BCD) in which four binary digits are used to encode each digit of a decimal number. With respect to the previous example, the decimal numbers 5 and 235 are represented as the binary values 0101 and 0010 0011 0101, respectively. Thus, instead of requiring 3 and 8 binary digits as described above, the BCD approach requires 3 and 10 binary digits to represent the same two numbers. Using the BCD approach, each digit is represented by a corresponding four binary digits as depicted in Table 1:
TABLE 1decimal5235binary (BCD)0101001000110101
Additional encoding methods seek to increase storage efficiency by encoding more decimal digits in a given number of binary digits, e.g., the Chen-Ho algorithm encodes three decimal digits into a corresponding 10 binary digits reaches a 99.66% storage efficiency. Increased storage efficiency through the use of complicated encoding algorithms comes at the expense of additional complexity, e.g., in terms of processing cost, i.e., additional processing time and/or specialized hardware.